//
//  DSDeviceListTableViewCell.m
//  RONGAO
//
//  Created by ZhangYeKun on 2017/2/25.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "DSDeviceListTableViewCell.h"

NSString * const kDSDeviceListIdentifier = @"kDSDeviceListIdentifier";

@interface DSDeviceListTableViewCell ()



@end

@implementation DSDeviceListTableViewCell

- (instancetype)init{
    
    if ([super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kDSDeviceListIdentifier]) {
        
        [self masLayoutSubview];
        
    }
    
    return self;
    
}

- (UIButton *)nicknameButton{
    
    if (!_nicknameButton) {
        
        __weak UIView *superView = self;
        _nicknameButton = [[UIButton alloc]init];
        [superView addSubview:_nicknameButton];
        [_nicknameButton setImage:[UIImage imageNamed:@"bg_door"] forState:UIControlStateNormal];
        [_nicknameButton setTitle:@"智慧门" forState:UIControlStateNormal];
        [_nicknameButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_nicknameButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
        
        _nicknameButton.titleEdgeInsets = UIEdgeInsetsMake(0, 15, 0, -25);
        [_nicknameButton setImageEdgeInsets:UIEdgeInsetsMake(0, 15, 0, -20)];
        _nicknameButton.userInteractionEnabled = NO;
        
    }
    
    return _nicknameButton;
    
}

- (UIButton *)onlineButton{
    
    if (!_onlineButton) {
        
        __weak UIView *superView = self;
        _onlineButton = [[UIButton alloc]init];
        [superView addSubview:_onlineButton];
        [_onlineButton setImage:[UIImage imageNamed:@"icon_offline"] forState:UIControlStateNormal];
        [_onlineButton setImage:[UIImage imageNamed:@"icon_online"] forState:UIControlStateSelected];
        [_onlineButton setTitle:@"在线" forState:UIControlStateNormal];
        [_onlineButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];

        _onlineButton.titleEdgeInsets = UIEdgeInsetsMake(0, -30, 0, -20);
        [_onlineButton setImageEdgeInsets:UIEdgeInsetsMake(0, -15, 0, 20)];

        [_onlineButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _onlineButton.userInteractionEnabled = NO;
        
    }
    
    return _onlineButton;
    
}

- (UIImageView *)videoImageView{
    
    if (!_videoImageView) {
        
        __weak UIView *superView = self;
        _videoImageView = [[UIImageView alloc]init];
        [_videoImageView setImage:[UIImage imageNamed:@"bg_31"]];
        [superView addSubview:_videoImageView];
        
    }
    
    return _videoImageView;
    
}

- (void)masLayoutSubview{
    
    __weak UIView *superView = self;
    [self.nicknameButton mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(superView.mas_left).mas_offset(10);
        make.bottom.mas_equalTo(superView.mas_bottom).mas_offset(-5);
        make.height.mas_equalTo(25);
        
    }];
    [self.onlineButton mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.right.mas_equalTo(superView.mas_right).mas_offset(-10);
        make.bottom.mas_equalTo(superView.mas_bottom).mas_offset(-5);
        make.height.mas_equalTo(25);
        
    }];
    [self.videoImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.top.mas_equalTo(superView);
        make.bottom.mas_equalTo(self.nicknameButton).mas_offset(-30);
        
    }];
}


- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
